#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define BUFSIZE 1024
void splitstr(char *str ,char *split, char **buf)
{
    char *result =  NULL;
    result = strtok(str,split);
    int i=0;
    printf("fun buf is %p \n",buf);
    while(result !=NULL)
    {
        
        *(buf+i) =  (char *)malloc(BUFSIZE * sizeof(char));
        printf("in fun buf %d add is %p \n",i,(buf+i));
        printf("in fun *buf %d add is %p \n",i,*(buf+i));
        memset(*(buf+i),0,BUFSIZE);
        strcpy(*(buf+i),result);
        i++;
        result = strtok(NULL,split);
    }
}

int main()
{
    char str[]="test # test #";
    char split[]="#";
    char **buf= (char **)malloc(sizeof(char *));
    splitstr(str,split,buf);
    char ** p = buf;
    printf("**p addr is %p \n",p);
    while((*p)!=NULL)
    {
        puts(*p);
        printf("in main  p is %p \n",p);
        printf("in main  *p is %p \n",*p);

        p++;
    }
    printf("char is %c",*(*(buf+1)+2));
    free(buf);
    return 0;
}


/**

fun buf is 0x100105420 
in fun buf 0 add is 0x100105420 
in fun *buf 0 add is 0x100801200 
in fun buf 1 add is 0x100105428 
in fun *buf 1 add is 0x100801600 
**p addr is 0x100105420 
test 
in main  p is 0x100105420 
in main  *p is 0x100801200 
 test 
in main  p is 0x100105428 
in main  *p is 0x100801600 
char is e

**/


